<%-- 
    Document   : display_cart
    Created on : Jan 13, 2012, 2:36:46 PM
    Author     : Fernando
--%>

<%@page import="com.sdd.plains.CartItem"%>
<%@page import="com.sdd.plains.ProductPlain"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.sdd.plains.CartPlain"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
            <input type="submit" value="Edit" id="editCart" onclick="getPage('edit_cart.jsp')"/>
            <input type="submit" value="Check out" id="checkOut" onclick="getPage('checkout_form.jsp')"/>
            <input type="submit" value="Reload" id="reload" onclick="loadCart()"/>
<%
    CartPlain cart = (CartPlain) request.getSession().getAttribute("cart");
    if(cart != null) {
        Iterator it = cart.iterator();
        CartItem ci;
        ProductPlain p;
        while(it.hasNext()) {
            ci = (CartItem) it.next();
            p = ci.getProduct();
%>
            <div class="cartproduct">
                <table>
                    <tr>
                        <td><img src="img/stewie.jpg" width="100" height="100" onclick="viewProduct('<%=p.getProductId()%>')"/></td>
                        <td>
                            <p onclick="viewProduct('<%=p.getProductId()%>')"><%=p.getName()%></p>
                            <p><%=p.getPrice()%> &euro;</p>
                            <p><%=ci.getQuantity()%></p>
                        </td>
                    </tr>
                </table>    
            </div>
<%
        }
    }
%>        
